import java.io.*;
import java.net.*;
public class SimpleSocketServer {
    public static void main(String[] args) {
        ServerSocket serverSocket = null;
        Socket socket = null;
        OutputStream os = null;
        InputStream is = null;

        int port = 10001;
        try {
            serverSocket = new ServerSocket(port);
            socket = serverSocket.accept();
            is = socket.getInputStream();
            byte[] b = new byte[1024];
            int n = is.read(b);
            System.out.println("Client Send:\t" + new String(b, 0, n));
            os = socket.getOutputStream();
            os.write(b, 0, n);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                os.close();
                is.close();
                socket.close();
                serverSocket.close();
            } catch (Exception e) {}
        }
    }

}
